//栈 - 比较含退格的字符串
class Solution {
public:
    string func(string s)
    {
        string ret;
        for(auto x : s)
        {
            if(ret.size() && x == '#') ret.pop_back();
            else 
            {
                if(x != '#')
                    ret.push_back(x);
            }
        }
        return ret;
    }

    bool backspaceCompare(string s, string t) 
    {
        return func(s) == func(t);
    }
};
